<!DOCTYPE html>
<html>
<head>
    <title>js面向对象-constructor-1</title>
    <meta charset="utf-8"/>
    <script src="../../js/jquery-1.10.1.min.js"></script>
    <script src="../../js/json2.js"></script>
    <script>

        // 空的构造函数
        function Person() {

        }

        Person.prototype = {
            init: function(name) {
                this.name = name;
            },
            getName: function() {
                return this.name;
            }
        };

        // 空的构造函数
        function Employee() {
        }

        // 创建类的阶段不会初始化父类的数据，因为Person是一个空的构造函数
        Employee.prototype = new Person();
        Employee.prototype.constructor = Employee;
        Employee.prototype.init = function(name, employeeID) {
            this.name = name;
            this.employeeID = employeeID;
        };

        Employee.prototype.getEmployeeID = function() {
            return this.employeeID;
        };

        var zhang = new Employee();
        //zhang.init("ZhangSan", "1234");
        console.log(zhang.getName()); //"ZhangSan"

    </script>
</head>
<body>

</body>
</html>